package com.xkw.autocode.web.systemlogs.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.github.pagehelper.PageInfo;
import com.xkw.autocode.base.BaseController;
import com.xkw.autocode.util.PageUtils;
import com.xkw.autocode.util.QueryUtils;
import com.xkw.autocode.vo.SystemLogsVo;
import com.xkw.autocode.web.common.Result;
import com.xkw.autocode.web.systemlogs.SystemLogsUrlUtil;
import com.xkw.autocode.web.systemlogs.ao.SystemLogsAo;

/**
 * “系统操作日志表” Controller类
 */
@Controller
public class SystemLogsController extends BaseController {

	@Autowired
	private SystemLogsAo systemLogsAo;

	/**
	 * 跳转到列表页面
	 */
	@RequestMapping(value = SystemLogsUrlUtil.LIST)
	public ModelAndView list() {
		ModelAndView modelAndView = new ModelAndView();

		modelAndView.setViewName("systemLogs/list");
		return modelAndView;
	}

	/**
	 * 获取列表页面的数据
	 */
	@RequestMapping(value = SystemLogsUrlUtil.LIST_DATA)
	@ResponseBody
	public Object listData(HttpServletRequest request, SystemLogsVo systemLogs) {

		QueryUtils query = QueryUtils.newInstance(request);
		PageInfo<SystemLogsVo> pageInfo = systemLogsAo.queryByPage(systemLogs, query.getPageNo(), query.getPageSize(),
				query.getOrderBy());

		return Result.ok().put("page", new PageUtils(pageInfo));
	}

}
